package com.zhentao.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhentao.dtos.Result;
import com.zhentao.mapper.ProductSpecMapper;
import com.zhentao.pojo.ProductSpec;
import com.zhentao.service.ProductSpecService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author 20183
* @description 针对表【product_spec(商品规格)】的数据库操作Service实现
* @createDate 2024-08-19 18:57:33
*/
@Service
public class ProductSpecServiceImpl extends ServiceImpl<ProductSpecMapper, ProductSpec>
    implements ProductSpecService{
    @Resource
    private ProductSpecMapper productSpecMapper;

    /**
     * 分页查询
     * @param page
     * @param limit
     * @return
     */
    @Override
    public PageInfo<ProductSpec> findByPage(Integer page, Integer limit) {
        PageHelper.startPage(page , limit) ;
        List<ProductSpec> productSpecList = productSpecMapper.findByPage();
        return new PageInfo<>(productSpecList);
    }

    @Override
    public List<ProductSpec> findAll() {
        return productSpecMapper.findAll();
    }

    @Override
    public Result deleteById(Long id) {
        productSpecMapper.deleteId(id);
        return Result.success();
    }
}




